package com.webcash.CNBoard.Repository;

import java.util.Date;
import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;

import com.webcash.CNBoard.Model.Document;
import com.webcash.CNBoard.Model.Project;

@Repository
public class ProjectRepositoryImpl extends SqlSessionDaoSupport implements ProjectRepository {
	
	public List<Project> selectProjectListById(String id) {
		SqlSession session = getSqlSession();
		
		
		return session.selectList("Project.selectProjectListById", id);
	}

	public Project selectProjectByProjectNo(int projectNo) {
		SqlSession session = getSqlSession();
		
		return session.selectOne("Project.selectProjectByProjectNo", projectNo);
	}

	public List<Document> selectDocumentListByProjectNo(int projectNo) {
		SqlSession session = getSqlSession();
		return session.selectList("Project.selectDocumentListByProjectNo", projectNo);
	}

	public void insertDocumentByDoc(Document doc) {
		SqlSession session = getSqlSession();
		
		
		session.insert("Project.insertDocumentByDoc", doc);
	}

	public Document selectDocumentByDocNo(int docNo) {
		SqlSession session = getSqlSession();
		
		return session.selectOne("Project.selectDocumnetByDocNo", docNo);
	}

	public int selectLastDocNo() {
		SqlSession session = getSqlSession();
		
		return session.selectOne("Project.selectLastDocNo");
	}

	public void deleteDocumentByDocNo(int docNo) {
		SqlSession session = getSqlSession();
		
		session.delete("Project.deleteDocumentByDocNo", docNo);
	}
	
	
	
}

